

<div class="fancy">
    <h4 style="width: 560px"><b><%= __('editEvent').c_event%></b></h4>
    <hr>
    <div>
    <form id="add_form" action="/updSchedule" method="post">
    <div style="margin-left: 50px">
        <input type="hidden" name="action" value="add">
        <p style="width: 100px;float: left;margin-top: 5px"><%= __('event').con %>：</p><input type="text"  name="title"  id="title" style="width:320px" placeholder="<%= __('event').record %>..." value="<%-title%>"></p>
        <div style="clear: both"></div>
        <p style="width: 100px;float: left;margin-top: 5px"><%= __('event').start %>：</p><input type="text" name="start" id="start" value="<%- start %>" onclick="WdatePicker()">
            <span id="sel_start" style="display:none"><select name="s_hour" style="width: 60px">
                    <option value="00">00</option>
                    <option value="01">01</option>
                    <option value="02">02</option>
                    <option value="03">03</option>
                    <option value="04">04</option>
                    <option value="05">05</option>
                    <option value="06">06</option>
                    <option value="07">07</option>
                    <option value="08" selected>08</option>
                    <option value="09">09</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option>
                    <option value="19">19</option>
                    <option value="20">20</option>
                    <option value="21">21</option>
                    <option value="22">22</option>
                    <option value="23">23</option>
                </select>:
                <select name="s_minute" style="width: 60px">
                    <option value="00" selected>00</option>
                    <option value="10">10</option>
                    <option value="20">20</option>
                    <option value="30">30</option>
                    <option value="40">40</option>
                    <option value="50">50</option>
                </select>
            </span>
        </p>
        <div style="clear: both"></div>
        <p id="p_endtime" style=<%- display %>>
            <span style="width: 100px;display: block;float: left"><%= __('event').end %>：</span>
            <input type="text"  name="end" id="end" value="<%- end %>" onclick="WdatePicker()">
            <span id="sel_end" style="display:none"><select name="e_hour" style="width: 60px">
            <option value="00">00</option>
            <option value="01">01</option>
            <option value="02">02</option>
            <option value="03">03</option>
            <option value="04">04</option>
            <option value="05">05</option>
            <option value="06">06</option>
            <option value="07">07</option>
            <option value="08">08</option>
            <option value="09">09</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12" selected>12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
        </select>:
    <select name="e_minute" style="width: 60px">
        <option value="00" selected>00</option>
        <option value="10">10</option>
        <option value="20">20</option>
        <option value="30">30</option>
        <option value="40">40</option>
        <option value="50">50</option>
    </select>
    </span>
        </p>
        <p>
            <label><input type="checkbox" value="1" id="isallday" name="isallday" checked><%= __('event').allday %></label>
            <label><input type="checkbox" value="1" id="isend" name="isend" <% if(checked){ %>checked<% }%>><%= __('event').end %></label>
        </p>

    </div>
    <hr>
    <div style="padding: 10px;">
        <input type="hidden" value="<%- _id %>" name="_id">
        <!--<input type="submit" class="btn btn-danger" value="删除">-->
        <a class="btn btn-danger" onclick="delevent('<%-_id %>','<%- color%>')"><%= __('editEvent').del %></a>
        <input type="button" class="btn btn_cancel" value="<%= __('event').cancel %>" onClick="$.fancybox.close()" style="float: right;margin-left: 15px">
        <input type="submit" class="btn btn-primary" value="<%= __('event').ok %>" style="float: right;">
    </div>
    </form>

</div>

<script type="text/javascript">
    function delevent(id,color){
        var prompt;
        if(color!='green'){
            prompt=confirm('<%= __('editEvent').alert1 %>？？');
        }else{
            prompt=confirm("<%= __('editEvent').alert2 %>？？");
        }

        if(prompt){
            $.ajax({
                url:'/delSchedule?id='+id,
                success:function(result){
                    if(result==1){
                        $.fancybox.close();
                        $('#calendar').fullCalendar('refetchEvents'); //重新获取所有事件数据
                    }else{
                        alert(result);
                    }
                }
            })
        }


    }
    $(function(){
        $("#isallday").click(function(){
            if($("#sel_start").css("display")=="none"){
                $("#sel_start,#sel_end").show();
            }else{
                $("#sel_start,#sel_end").hide();
            }
        });

        $("#isend").click(function(){
            if($("#p_endtime").css("display")=="none"){
                $("#p_endtime").show();
            }else{
                $("#p_endtime").hide();
            }
            $.fancybox.resize();//调整高度自适应
        });

        //提交表单
        $('#add_form').ajaxForm({
            beforeSubmit: showRequest, //表单验证
            success: showResponse //成功返回
        });
    });

    function showRequest(){
        var events = $("#title").val();
        if(events==''){
            alert("<%= __('event').alert%>！");
            $("#event").focus();
            return false;
        }
    }
    function showResponse(responseText, statusText, xhr, $form){

//        if(statusText=="success"){

            if(responseText==1){
                $.fancybox.close();
                $('#calendar').fullCalendar('refetchEvents'); //重新获取所有事件数据
            }else{
                alert(responseText);
                alert('111')
            }
//        }else{
//            alert(statusText);
//        }
    }
</script>